13. Exercise: Add an IntentService
Adding an Intent Service
Add an IntentService
In this exercise, you'll add the ability to increment the water count, using a Service.
Exercise Code
Exercise: T10.01-Exercise-IntentServices
Exercise: Intent Services
SOLUTION:
- Create the `ReminderTasks` helper class along with the `incrementWaterCount` and `executeTask` methods
- Create `WaterReminderIntentService` by overriding an `IntentService`
- Increment the water count when `onHandleIntent` gets the `ACTION_INCREMENT_WATER_COUNT`
- Register `WaterReminderIntentService` in the manifest
- Start the `IntentService` with `ACTION_INCREMENT_WATER_COUNT` from `incrementWater` in `MainActivity`